package com.alipay.fileUplaod;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.FileItem;
import com.alipay.api.request.AlipayOfflineMaterialImageUploadRequest;
import com.alipay.api.response.AlipayOfflineMaterialImageUploadResponse;
import com.alipay.factory.AlipayAPIClientFactory;

/**
 * 卡卷相关业务调用接口
 * 
 * @author zwm
 *
 */
public class FileManage {

	public static void main(String[] args) throws AlipayApiException {
		uploadImage();
	}

	// 图片资料上传
	public static void uploadImage() throws AlipayApiException {
		
		AlipayClient alipayClient = AlipayAPIClientFactory.getAlipayClient();
		AlipayOfflineMaterialImageUploadRequest alipayRequest = new AlipayOfflineMaterialImageUploadRequest();
		alipayRequest.setImageType("png"); //图片类型，当前支持bmp,png,jpeg,jpg,gif 5个类型
		alipayRequest.setImageName("图片名称");
		FileItem ImageContent = new FileItem("e:/image/2.png"); //图片文件路径
		alipayRequest.setImageContent(ImageContent);
		 
		AlipayOfflineMaterialImageUploadResponse alipayResponse = alipayClient.execute(alipayRequest);
		System.out.println(alipayResponse.getImageId()); //  获取图片资源ID
		System.out.println(alipayResponse.getImageUrl()); // 获取图片访问链接
		System.out.println(alipayResponse.getCode()); // 获取接口结果码
		System.out.println(alipayResponse.getSubCode()); // 当接口调用失败后，获取子错误码
		System.out.println(alipayResponse.getMsg()); // 获取子错误描述
		System.out.println(alipayResponse.getBody()); // 获取完整的返回报文
	}

}
